<!doctype html>
<html>

	<head>
		<meta charset="utf-8">
		<title></title>
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<link href="css/mui.css" rel="stylesheet" />
		<script src="js/mui.js"></script>
		<script src="./utils/myRequest.js"></script>
		<script type="text/javascript">
			mui.init();
			mui.plusReady(function () {
			    document.getElementById("sendMail").addEventListener("tap",function(){
					//发件人邮箱
					var fromName = document.getElementById("fromName").value;
					//获取收件人的邮箱
					var toName = document.getElementById("toName").value;
					//获取主题
					var title = document.getElementById("title").value;
					//获取邮箱内容
					var content = document.getElementById("content").value;
					
					var param = new Object();
					param.fromName = fromName;
					param.toName = toName;
					param.title = title;
					param.content = content;
					
					request.ajax({
						url : "/mail/sendMail",
						data : param,
						type : "post",
						success:function(resp){
							console.log( typeof resp);
							if(resp.code === 20000){
								plus.nativeUI.toast(resp.message);
								//两秒后跳转到发现页面
								//跳转到发现页面
								plus.webview.open("./find.html","find.html");
								//关闭当前页
								plus.webview.currentWebview().close();
								// setTimeout(function() {
									
								// }, 2000);
							}else if(resp.code === 20001){
								plus.nativeUI.toast(resp.message);
							}
						}
					});
					
				});
			});
		</script>
	</head>

	<body>
		<header class="mui-bar mui-bar-nav">
			<a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left"></a>
			<h1 class="mui-title">发邮箱</h1>
		</header>
		
		<div style="margin-top: 50px;">
			<form class="mui-input-group">
			    <div class="mui-input-row">
			        <label>发件人</label>
					<input type="text" class="mui-input-clear" id="fromName" value="ganmaowang@qq.com" disabled="disabled"  placeholder="请输入发件人">
			    </div>
			    <div class="mui-input-row">
			        <label>收件人</label>
			        <input type="text" id="toName"  class="mui-input-clear" placeholder="请输入收件人">
			    </div>
			    <div class="mui-input-row">
			        <label>主题</label>
			        <input type="text" id="title"   class="mui-input-clear" placeholder="请输入邮箱主题">
			    </div>
				<div style="margin-top: 10px;">
				    <label style="margin-left: 15px;font-weight: 700;">正文</label>
					<hr />
					<textarea id="content" style="height: 200px;">请输入邮箱内容...</textarea>
				</div>
			</form>
			
			<ul class="mui-table-view" style="text-align: center;color: white;background-color: #2AC845;">
				<li class="mui-table-view-cell mui-media" id="sendMail">
					<a href="javascript:;">
						发送
					</a>
				</li>
			</ul>
		</div>
	</body>

</html>
